/*
 * Users_MemManage.h
 *
 *  Created on: Aug 8, 2020
 *      Author: MrWang
 */

#ifndef USERS_FILES_USERS_MEMORY_USERS_MEMMANAGE_H_
#define USERS_FILES_USERS_MEMORY_USERS_MEMMANAGE_H_

#include "main.h"

//XXX !!!!!!!  free point must set to null,before free must check it is not NULL   !!!!!!!!!!!
#ifdef RT_USING_MEMPOOL

extern void Users_Mem_Init(void);
extern void* Users_Malloc(uint32_t len);
#define	Users_Free(x)		do{if(x != NULL){rt_mp_free(x);(x) = NULL;}}while(0)

#else

#define Users_Mem_Init		__NOP
#define Users_Malloc		rt_malloc
#define	Users_Free(x)		do{if(x != NULL){rt_free(x);(x) = NULL;}}while(0)

#endif

#endif /* USERS_FILES_USERS_MEMORY_USERS_MEMMANAGE_H_ */
